package com.interest.plus2.view.mainview;

import ohos.agp.components.AttrSet;
import ohos.agp.components.Component;
import ohos.agp.components.DependentLayout;
import ohos.agp.components.LayoutScatter;
import ohos.app.Context;

/**
 * app首页base页面
 */
public abstract class BaseView extends DependentLayout {
    public BaseView(Context context) {
        super(context);
        setContent(context);
    }

    public BaseView(Context context, AttrSet attrSet) {
        super(context, attrSet);
        setContent(context);
    }

    public BaseView(Context context, AttrSet attrSet, String styleName) {
        super(context, attrSet, styleName);
        setContent(context);
    }

    void setContent(Context context) {
        LayoutScatter.getInstance(context).parse(getLayoutId(), this, true);
        initView();
    }

    /**
     * 返回 布局ID
     *
     * @return resId
     */
    abstract int getLayoutId();

    /**
     * 初始化view
     */
    abstract void initView();

}
